package com.dimples.dd.system.convert;

import com.dimples.dd.common.model.Option;
import com.dimples.dd.common.pojo.PageResult;
import com.dimples.dd.system.model.entity.SystemRoleDO;
import com.dimples.dd.system.model.form.RoleForm;
import com.dimples.dd.system.model.vo.RolePageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * 角色对象转换器
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/7/3
 */
@Mapper(componentModel = "spring")
public interface RoleConverter {

    @Mappings({
            @Mapping(target = "value", source = "code"),
            @Mapping(target = "label", source = "name"),
    })
    Option<String> entity2Option(SystemRoleDO role);

    List<Option<String>> entities2Options(List<SystemRoleDO> roles);

    PageResult<RolePageVO> entity2Page(PageResult<SystemRoleDO> rolePage);

    SystemRoleDO form2Entity(RoleForm roleForm);

    RoleForm entity2Form(SystemRoleDO entity);
}
